﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Server2
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Server s1;
        public MainWindow()
        {
            InitializeComponent();
            
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            s1 = new Server("Server1");
            s1.changeSalon += new changeHandler(refreshListeServer);
            refreshListeServer();
            mainText.Text = "Bienvenu sur la gestion du Server.\ntapez /help pour la liste des commandes";
        }

        private void envoi_Click(object sender, RoutedEventArgs e)
        {
            string a = s1.ReqAnalyse(inputText.Text);
            
            if (!a.Equals(""))
            {
                mainText.Text = a;
            }
            
            inputText.Text = "";

        }

        private void refreshListeServer()
        {
            listeServer.Items.Clear();
            foreach (Salon s in s1.SalonList)
            {
                listeServer.Items.Add(s.Name);
            }
        }

        
    }
}
